package is.BlackWhiteSquares.formulas;



public class Casilla implements Cloneable {

	public static enum ColorCasilla {
		WHITE,
		BLACK;
	}
	
	private ColorCasilla color;

	
	public Casilla(ColorCasilla color) {
		this.color= color;
	}
	public Casilla (String c){
		
		c=color.toString();
		
	}
    public ColorCasilla getColor() {
		return this.color;
	}

	public void setColor(ColorCasilla color) {
		this.color = color;
	}

	public boolean equals(Object obj) {   
		if (obj != null && obj instanceof Casilla && (this.getColor()== ((Casilla) obj).getColor())) {
			return true;
		} else {
			return false;
		}
	}

	
	
	public Object clone() {
		Object clon = null;
		
		try {
			clon = super.clone();			
		} catch (CloneNotSupportedException e) {
			System.err.println("% [ERROR] Casilla.clone(): " + e.getMessage());
		}
		
		return clon;		
	}

	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Casilla casilla = new Casilla(ColorCasilla.BLACK);
		System.out.println("color:"+casilla.getColor().toString());
		
		Casilla casilla2 =(Casilla) casilla.clone();
		System.out.println("casilla clonada");
		casilla2.setColor(ColorCasilla.WHITE);
		System.out.println("color de la segunda casilla:"+casilla2.getColor().toString());
		
	    if(casilla.equals(casilla2)){
		   System.out.println("las casillas son iguales");
	      }else{
		   System.out.println("las casillas son diferentes");
	}
		
	}

}
